
package playground;

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.PrintStream;

/**
 *
 * @author badi
 */
public class Main {

    enum Choice { Worker, Generator }

    static String file;

    final static int socket = 3000;

    public static void main(String[] args)  {
        file = args[0];

        if(args[1].equalsIgnoreCase("worker")){
            new Worker(file, socket).run();
        }

        else if (args[1].equalsIgnoreCase("generator")){
            new Generator(file, socket).run();
        }
    }

    public static void write (Object o, OutputStream s) throws IOException{
        ObjectOutputStream oos = new ObjectOutputStream(s);
        oos.writeObject(o);
        oos.flush();
        oos = null;
    }

    public static Object read (InputStream s) throws IOException, ClassNotFoundException{
        ObjectInputStream ois = new ObjectInputStream(s);
        Object o = ois.readObject();
        ois = null;
        return o;
    }

}
